home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / management / MBeanInfo.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  6.5 KB  |  249 lines

  1. package javax.management;
  2.  
  3. import [Ljavax.management.MBeanAttributeInfo;;
  4. import [Ljavax.management.MBeanConstructorInfo;;
  5. import [Ljavax.management.MBeanNotificationInfo;;
  6. import [Ljavax.management.MBeanOperationInfo;;
  7. import java.io.IOException;
  8. import java.io.ObjectInputStream;
  9. import java.io.ObjectOutputStream;
  10. import java.io.Serializable;
  11. import java.io.StreamCorruptedException;
  12. import java.security.AccessController;
  13. import java.util.Arrays;
  14. import java.util.Map;
  15. import java.util.WeakHashMap;
  16.  
  17. public class MBeanInfo implements Cloneable, Serializable, DescriptorRead {
  18.    static final long serialVersionUID = -6451021435135161911L;
  19.    private transient Descriptor descriptor;
  20.    private final String description;
  21.    private final String className;
  22.    private final MBeanAttributeInfo[] attributes;
  23.    private final MBeanOperationInfo[] operations;
  24.    private final MBeanConstructorInfo[] constructors;
  25.    private final MBeanNotificationInfo[] notifications;
  26.    private transient int hashCode;
  27.    private final transient boolean arrayGettersSafe;
  28.    private static final Map<Class, Boolean> arrayGettersSafeMap = new WeakHashMap();
  29.  
  30.    public MBeanInfo(String var1, String var2, MBeanAttributeInfo[] var3, MBeanConstructorInfo[] var4, MBeanOperationInfo[] var5, MBeanNotificationInfo[] var6) throws IllegalArgumentException {
  31.       this(var1, var2, var3, var4, var5, var6, (Descriptor)null);
  32.    }
  33.  
  34.    public MBeanInfo(String var1, String var2, MBeanAttributeInfo[] var3, MBeanConstructorInfo[] var4, MBeanOperationInfo[] var5, MBeanNotificationInfo[] var6, Descriptor var7) throws IllegalArgumentException {
  35.       this.className = var1;
  36.       this.description = var2;
  37.       if (var3 == null) {
  38.          var3 = MBeanAttributeInfo.NO_ATTRIBUTES;
  39.       }
  40.  
  41.       this.attributes = var3;
  42.       if (var5 == null) {
  43.          var5 = MBeanOperationInfo.NO_OPERATIONS;
  44.       }
  45.  
  46.       this.operations = var5;
  47.       if (var4 == null) {
  48.          var4 = MBeanConstructorInfo.NO_CONSTRUCTORS;
  49.       }
  50.  
  51.       this.constructors = var4;
  52.       if (var6 == null) {
  53.          var6 = MBeanNotificationInfo.NO_NOTIFICATIONS;
  54.       }
  55.  
  56.       this.notifications = var6;
  57.       if (var7 == null) {
  58.          var7 = ImmutableDescriptor.EMPTY_DESCRIPTOR;
  59.       }
  60.  
  61.       this.descriptor = (Descriptor)var7;
  62.       this.arrayGettersSafe = arrayGettersSafe(this.getClass(), MBeanInfo.class);
  63.    }
  64.  
  65.    public Object clone() {
  66.       try {
  67.          return super.clone();
  68.       } catch (CloneNotSupportedException var2) {
  69.          return null;
  70.       }
  71.    }
  72.  
  73.    public String getClassName() {
  74.       return this.className;
  75.    }
  76.  
  77.    public String getDescription() {
  78.       return this.description;
  79.    }
  80.  
  81.    public MBeanAttributeInfo[] getAttributes() {
  82.       MBeanAttributeInfo[] var1 = this.nonNullAttributes();
  83.       return var1.length == 0 ? var1 : (MBeanAttributeInfo[])((MBeanAttributeInfo[])((MBeanAttributeInfo;)var1).clone());
  84.    }
  85.  
  86.    private MBeanAttributeInfo[] fastGetAttributes() {
  87.       return this.arrayGettersSafe ? this.nonNullAttributes() : this.getAttributes();
  88.    }
  89.  
  90.    private MBeanAttributeInfo[] nonNullAttributes() {
  91.       return this.attributes == null ? MBeanAttributeInfo.NO_ATTRIBUTES : this.attributes;
  92.    }
  93.  
  94.    public MBeanOperationInfo[] getOperations() {
  95.       MBeanOperationInfo[] var1 = this.nonNullOperations();
  96.       return var1.length == 0 ? var1 : (MBeanOperationInfo[])((MBeanOperationInfo[])((MBeanOperationInfo;)var1).clone());
  97.    }
  98.  
  99.    private MBeanOperationInfo[] fastGetOperations() {
  100.       return this.arrayGettersSafe ? this.nonNullOperations() : this.getOperations();
  101.    }
  102.  
  103.    private MBeanOperationInfo[] nonNullOperations() {
  104.       return this.operations == null ? MBeanOperationInfo.NO_OPERATIONS : this.operations;
  105.    }
  106.  
  107.    public MBeanConstructorInfo[] getConstructors() {
  108.       MBeanConstructorInfo[] var1 = this.nonNullConstructors();
  109.       return var1.length == 0 ? var1 : (MBeanConstructorInfo[])((MBeanConstructorInfo[])((MBeanConstructorInfo;)var1).clone());
  110.    }
  111.  
  112.    private MBeanConstructorInfo[] fastGetConstructors() {
  113.       return this.arrayGettersSafe ? this.nonNullConstructors() : this.getConstructors();
  114.    }
  115.  
  116.    private MBeanConstructorInfo[] nonNullConstructors() {
  117.       return this.constructors == null ? MBeanConstructorInfo.NO_CONSTRUCTORS : this.constructors;
  118.    }
  119.  
  120.    public MBeanNotificationInfo[] getNotifications() {
  121.       MBeanNotificationInfo[] var1 = this.nonNullNotifications();
  122.       return var1.length == 0 ? var1 : (MBeanNotificationInfo[])((MBeanNotificationInfo[])((MBeanNotificationInfo;)var1).clone());
  123.    }
  124.  
  125.    private MBeanNotificationInfo[] fastGetNotifications() {
  126.       return this.arrayGettersSafe ? this.nonNullNotifications() : this.getNotifications();
  127.    }
  128.  
  129.    private MBeanNotificationInfo[] nonNullNotifications() {
  130.       return this.notifications == null ? MBeanNotificationInfo.NO_NOTIFICATIONS : this.notifications;
  131.    }
  132.  
  133.    public Descriptor getDescriptor() {
  134.       return (Descriptor)ImmutableDescriptor.nonNullDescriptor(this.descriptor).clone();
  135.    }
  136.  
  137.    public String toString() {
  138.       return this.getClass().getName() + "[" + "description=" + this.getDescription() + ", " + "attributes=" + Arrays.asList(this.fastGetAttributes()) + ", " + "constructors=" + Arrays.asList(this.fastGetConstructors()) + ", " + "operations=" + Arrays.asList(this.fastGetOperations()) + ", " + "notifications=" + Arrays.asList(this.fastGetNotifications()) + ", " + "descriptor=" + this.getDescriptor() + "]";
  139.    }
  140.  
  141.    public boolean equals(Object var1) {
  142.       if (var1 == this) {
  143.          return true;
  144.       } else if (!(var1 instanceof MBeanInfo)) {
  145.          return false;
  146.       } else {
  147.          MBeanInfo var2 = (MBeanInfo)var1;
  148.          if (isEqual(this.getClassName(), var2.getClassName()) && isEqual(this.getDescription(), var2.getDescription()) && this.getDescriptor().equals(var2.getDescriptor())) {
  149.             return Arrays.equals(var2.fastGetAttributes(), this.fastGetAttributes()) && Arrays.equals(var2.fastGetOperations(), this.fastGetOperations()) && Arrays.equals(var2.fastGetConstructors(), this.fastGetConstructors()) && Arrays.equals(var2.fastGetNotifications(), this.fastGetNotifications());
  150.          } else {
  151.             return false;
  152.          }
  153.       }
  154.    }
  155.  
  156.    public int hashCode() {
  157.       if (this.hashCode != 0) {
  158.          return this.hashCode;
  159.       } else {
  160.          this.hashCode = this.getClassName().hashCode() ^ this.getDescriptor().hashCode() ^ arrayHashCode(this.fastGetAttributes()) ^ arrayHashCode(this.fastGetOperations()) ^ arrayHashCode(this.fastGetConstructors()) ^ arrayHashCode(this.fastGetNotifications());
  161.          return this.hashCode;
  162.       }
  163.    }
  164.  
  165.    private static int arrayHashCode(Object[] var0) {
  166.       int var1 = 0;
  167.  
  168.       for(int var2 = 0; var2 < var0.length; ++var2) {
  169.          var1 ^= var0[var2].hashCode();
  170.       }
  171.  
  172.       return var1;
  173.    }
  174.  
  175.    static boolean arrayGettersSafe(Class var0, Class var1) {
  176.       if (var0 == var1) {
  177.          return true;
  178.       } else {
  179.          synchronized(arrayGettersSafeMap) {
  180.             Boolean var3 = (Boolean)arrayGettersSafeMap.get(var0);
  181.             if (var3 == null) {
  182.                try {
  183.                   ArrayGettersSafeAction var4 = new ArrayGettersSafeAction(var0, var1);
  184.                   var3 = (Boolean)AccessController.doPrivileged(var4);
  185.                } catch (Exception var6) {
  186.                   var3 = false;
  187.                }
  188.  
  189.                arrayGettersSafeMap.put(var0, var3);
  190.             }
  191.  
  192.             return var3;
  193.          }
  194.       }
  195.    }
  196.  
  197.    private static boolean isEqual(String var0, String var1) {
  198.       boolean var2;
  199.       if (var0 == null) {
  200.          var2 = var1 == null;
  201.       } else {
  202.          var2 = var0.equals(var1);
  203.       }
  204.  
  205.       return var2;
  206.    }
  207.  
  208.    private void writeObject(ObjectOutputStream var1) throws IOException {
  209.       var1.defaultWriteObject();
  210.       if (this.descriptor.getClass() == ImmutableDescriptor.class) {
  211.          var1.write(1);
  212.          String[] var2 = this.descriptor.getFieldNames();
  213.          var1.writeObject(var2);
  214.          var1.writeObject(this.descriptor.getFieldValues(var2));
  215.       } else {
  216.          var1.write(0);
  217.          var1.writeObject(this.descriptor);
  218.       }
  219.  
  220.    }
  221.  
  222.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  223.       var1.defaultReadObject();
  224.       switch (var1.read()) {
  225.          case -1:
  226.             this.descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
  227.             break;
  228.          case 0:
  229.             this.descriptor = (Descriptor)var1.readObject();
  230.             if (this.descriptor == null) {
  231.                this.descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
  232.             }
  233.             break;
  234.          case 1:
  235.             String[] var2 = (String[])var1.readObject();
  236.             if (var2.length == 0) {
  237.                this.descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
  238.             } else {
  239.                Object[] var3 = var1.readObject();
  240.                this.descriptor = new ImmutableDescriptor(var2, var3);
  241.             }
  242.             break;
  243.          default:
  244.             throw new StreamCorruptedException("Got unexpected byte.");
  245.       }
  246.  
  247.    }
  248. }
  249.